/**
 * 
 */
package galacticthrone.main;

import galacticthrone.empire.Empire;
import galacticthrone.map.GalacticMap;
import galacticthrone.screen.map.MapState;
import galacticthrone.screen.menu.MenuState;

import java.util.HashSet;
import java.util.Set;

import javagame.core.main.Game;
import javagame.core.main.GameState;
import javagame.core.main.GameWindow;
import javagame.impl.io.video.texture.SimpleTextureManager;

// TODO Javadoc
/**
 * <br>
 *
 * @author Jaco van der Westhuizen
 */
public class GTGame extends Game
{
    private Empire player = null;
	private boolean isStatesReady = false;
    private Set<GameState> states;
    private GalacticMap gameMap = null;

    public static GameState MENU;
    public static GameState MAP;
    public static GameState DIPLOMACY;
    public static GameState SHIP_DESIGN;
    public static GameState SPACE_COMBAT;
    public static GameState GROUND_COMBAT;
    public static GameState NEW_GAME;
    public static GameState SAVE_LOAD;
    public static GameState SETTINGS;

    public static SimpleTextureManager texManager = null;

    public GTGame()
    {
    	super(60);
    }

    /* (non-Javadoc)
     * @see javagame.core.main.game.Game#getGameStates()
     */
    @Override
    protected Set<GameState> getGameStates()
    {
        if (!isStatesReady)
        {
            states = new HashSet<GameState>();

            MENU = new MenuState();
            MAP = new MapState();

            states.add(MENU);
            states.add(MAP);
            
            isStatesReady = true;
        }

        return states;
    }

    /* (non-Javadoc)
     * @see javagame.core.main.game.Game#getInitialGameState()
     */
    @Override
    protected GameState getInitialGameState()
    {
        return MENU;
    }

    /* (non-Javadoc)
     * @see javagame.core.main.game.Game#createGameWindow()
     */
    @Override
    protected GameWindow createGameWindow()
    {
        return new GTWindow();
    }

    public static GTGame get()
    {
        return (GTGame)Game.get();
    }

    public static GalacticMap getGameMap()
    {
        return get().gameMap;
    }
    
    public static void setGameMap(GalacticMap newMap)
    {
    	get().gameMap = newMap;
    }
    
    public static Empire getPlayerEmpire()
    {
    	return get().player;
    }
    
    public static SimpleTextureManager getTextureManager()
    {
    	if (texManager == null)
    	{
    		texManager = new SimpleTextureManager();
    	}
    	
    	return texManager;
    }
}
